#include<iostream>


class Animal
{
public:
    virtual void speak()
    {
        std::cout<<"动物叫"<<std::endl;
    }
    virtual ~Animal()//虚析构函数
    {
        std::cout<<"父类析构函数\n";
    }
};
class Dog:public Animal
{
    public:
        void speak()
        {
            std::cout<<"汪汪汪"<<std::endl;
        }
         ~Dog()
    {
        std::cout<<"子类析构函数\n";
    }
};
class cat:public Animal
{
    public:
        void speak()
        {
            std::cout<<"喵喵喵"<<std::endl;
        }
         ~cat()
    {
        std::cout<<"子类析构函数\n";
    }
};
void Show(Animal *a)
{
    a->speak();
}


int main()
{
    Animal *a=new Dog;
    Animal *b=new cat;


    Show(a);
    Show(b);
    delete a;
    delete b;
    return 0;

}